﻿using System;
using System.IO;
using UnityEngine;
using XLua;
[CSharpCallLua]
public interface Table
{
    int k { get; set; }
    int v { get; set; }
}
public class TestLua : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        LuaEnv lua = new LuaEnv();
        string main = "require('main')";
        lua.AddLoader(loader);
        lua.DoString(main);
        CreatObj = lua.Global.Get<Action>("CreateObject");
        //CreatObj?.Invoke();
        t= lua.Global.Get<Table>("table");
        Debug.Log(t.k + "   " + t.v);
    }
    Action CreatObj;
    Table t;
    private byte[] loader(ref string filepath)
    {
        return File.ReadAllBytes(Application.dataPath + "/Resources/" + filepath + ".lua");
    }



    // Update is called once per frame
    void Update()
    {
        
    }
}
